﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ElingOA6_Admin_DSJCJ.Common;

namespace ElingOA6_Admin_DSJCJ.Areas.Admin.Controllers
{
    /// <summary>
    /// 信息年度结转
    /// </summary>
    [OutputCache(Duration = 0, VaryByParam = "none")]
    public class DocYearTransferController : AdminBaseController
    {
        //
        // GET: /Admin/DocYearTransfer/
        //m_DocYearTransfer

        private BLL.DocClsScore docClsScoreBLL = new BLL.DocClsScore();

        /// <summary>
        /// 信息年度结转
        /// </summary>
        /// <returns></returns>
        [AuthorityActionFilter("m_DocYearTransfer", Order = 1)]
        [LogPageActionFilter("信息年度结转", Order = 2)]
        public ActionResult Index()
        {
            string entityNo = GlobalConstant.ENTITYNO;
            int maxYear = docClsScoreBLL.GetMaxYear(entityNo);

            ViewData["currentYear"] = maxYear;

            return View();
        }
        /// <summary>
        /// 年度结转
        /// </summary>
        /// <param name="year"></param>
        /// <returns></returns>
        public ActionResult YearTurn(int year)
        {
            string entityNo = GlobalConstant.ENTITYNO;
            if (docClsScoreBLL.YearTurn(entityNo, year) != -1)
            {
                Response.Write("<script>window.alert('结转成功！');window.location.href='" + Url.Content("~/Admin/DocYearTransfer") + "'</script>");
            }
            else
            {
                Response.Write("<script>window.alert('结转失败！');window.location.href='" + Url.Content("~/Admin/DocYearTransfer") + "'</script>");
            }
            Response.Flush();
            Response.End();
            return null;
        }
        /// <summary>
        /// 年度反结转
        /// </summary>
        /// <returns></returns>
        public ActionResult YearChange(int year)
        {
            string entityNo = GlobalConstant.ENTITYNO;
            if (docClsScoreBLL.YearTurnChange(entityNo, year) != -1)
            {
                Response.Write("<script>window.alert('反结转成功！');window.location.href='" + Url.Content("~/Admin/DocYearTransfer") + "'</script>");
            }
            else
            {
                Response.Write("<script>window.alert('反结转失败！');window.location.href='" + Url.Content("~/Admin/DocYearTransfer") + "'</script>");
            }
            Response.Flush();
            Response.End();
            return null;
        }
    }
}
